package Servlet;

import MySql.MySqlTool;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by liushiyin on 17-11-17.
 */
public class LoginBlogVerify extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        request.setCharacterEncoding("UTF-8");
        String author=request.getParameter("login");
        String pwd=request.getParameter("pwd");

        MySqlTool sqlTool=new MySqlTool();
        boolean b=sqlTool.QueryExits("select * from author where authorname='"+author+"'"+" and authorpwd='"+pwd+"'");
        sqlTool.close();
        if(b){
            request.setAttribute("status","islogin");
            request.getRequestDispatcher("EditBlog.jsp").forward(request,response);
        }else{
            request.setAttribute("error","failed");
            request.getRequestDispatcher("Login.jsp").forward(request,response);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


    }
}
